package com.ruoyi.system.service.impl;

import java.util.List;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.TReason;
import com.ruoyi.system.domain.TUser;
import com.ruoyi.system.service.ITReasonService;
import com.ruoyi.system.service.ITUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.TCompanyMapper;
import com.ruoyi.system.domain.TCompany;
import com.ruoyi.system.service.ITCompanyService;

import javax.annotation.Resource;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-04-06
 */
@Service
public class TCompanyServiceImpl implements ITCompanyService 
{
    @Autowired
    private TCompanyMapper tCompanyMapper;

    @Resource
    private ITUserService itUserService;

    @Resource
    private ITReasonService itReasonService;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public TCompany selectTCompanyById(Long id)
    {
        return tCompanyMapper.selectTCompanyById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param tCompany 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<TCompany> selectTCompanyList(TCompany tCompany)
    {
        return tCompanyMapper.selectTCompanyList(tCompany);
    }

    /**
     * 新增
     * 
     * @param tCompany
     * @return 结果
     */
    @Override
    public int insertTCompany(TCompany tCompany)
    {
        tCompany.setApiKey(SecurityUtils.getUUID());
        tCompanyMapper.insertTCompany(tCompany);

        TUser tUser=new TUser();
        tUser.setLoginName(tCompany.getCompanyEmail());
        tUser.setUpass("123456");
        tUser.setRoleName("3");
        tUser.setRoleId(Long.valueOf(3));
        tUser.setUname(tCompany.getCompanyName());
        tUser.setOfCompany(tCompany.getId());
        int i=itUserService.insertTUser(tUser);

        return i;
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param tCompany 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updateTCompany(TCompany tCompany)
    {
        return tCompanyMapper.updateTCompany(tCompany);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTCompanyByIds(Long[] ids)
    {
        return tCompanyMapper.deleteTCompanyByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deleteTCompanyById(Long id)
    {
        return tCompanyMapper.deleteTCompanyById(id);
    }
}
